package com.dididoctor.patient.Receive;

import android.content.Context;
import android.content.Intent;

import com.dididoctor.patient.Activity.ConstantValue;
import com.dididoctor.patient.Activity.Evaluate.EvaluateActivity;
import com.dididoctor.patient.Bean.Token;
import com.dididoctor.patient.MV.BasePresenter;
import com.dididoctor.patient.MV.BusinessClient;
import com.dididoctor.patient.MV.FastHttpResponseHandler;
import com.dididoctor.patient.MV.Response;
import com.loopj.android.http.RequestParams;

import org.apache.http.Header;


/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： xmppPresenter
 * @包名称： com.dididoctor.patient.Activity.Consult
 * @创建人： zhanjunjie
 * @创建时间：2016/4/7 11:05
 * @修改人：
 * @修改时间：2016/4/7 11:05
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class xmppPresenter extends BasePresenter {

    private xmppView view;
    private Context context;

    public xmppPresenter(Context context) {
        super();
        this.context = context;
    }

    //    recId,hosId,userid,token
    public void getgoAndFrom(final String recId, final String hosId, final String userid, final String token, final String doctorId, final String accId, final String name, final String sign) {
        RequestParams params = new RequestParams();
        params.put("userId", Token.getId());
        params.put("token", Token.getToken());
        params.put("recId", recId);
        BusinessClient.post(ConstantValue.medicalendUrl, params, new FastHttpResponseHandler() {
            private String hasDoctor = "";//是否有签约医生1有0没有

            @Override
            public void onResponse(Response response) {

                if ("1".equals(response.getStatus())) {
//                    view.isOK();
                    Intent intent1 = new Intent(context, EvaluateActivity.class);
                    intent1.putExtra("recId", recId);
                    intent1.putExtra("hosId", hosId);
                    intent1.putExtra("userid", userid);
                    intent1.putExtra("token", token);
                    intent1.putExtra("doctorid", doctorId);
                    intent1.putExtra("accId", accId);
                    intent1.putExtra("name", name);
                    intent1.putExtra("iszq", true);
                    intent1.putExtra("sign", sign);
                    intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//                    intent1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    context.startActivity(intent1);
                } else {
                    view.isBall();
                }

            }

            @Override
            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                super.onFailure(i, headers, bytes, throwable);
            }
        });
    }

}
